package com.web.bridge.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.web.bridge.dao.IBaseDAO;
import com.web.bridge.service.IBaseService;

@Service
public class BaseServiceImpl<T> implements IBaseService<T> {
	@Autowired
	private IBaseDAO<T> baseDao;

	// public void setBaseDao(IBaseDAO<T> baseDao){
	// this.baseDao=baseDao;
	// }

	@Override
	public T add(T t) {
		// TODO Auto-generated method stub
		baseDao.save(t);
		return t;
	}

	@Override
	public T update(T t) {
		// TODO Auto-generated method stub
		baseDao.update(t);
		return t;
	}

	@Override
	public void delete(T t) {
		// TODO Auto-generated method stub
		baseDao.delete(t);
	}

	@Override
	public T get(Class<T> entityClazz, Long id) {
		// TODO Auto-generated method stub
		return baseDao.findById(entityClazz, id);
	}

	@Override
	public List<T> listAll(Class<T> entityClazz) {
		// TODO Auto-generated method stub
		return baseDao.findAll(entityClazz);
	}

	@Override
	public void delete(Class<T> entityClazz, Long id) {
		// TODO Auto-generated method stub
		baseDao.delete(entityClazz, id);
	}

}
